;; Nazim Khan
;; TechGuruPlus.com
;; YouTube.com/TechGuruPlus





[System	: Formula]
	IsEnableDepreciation	: Yes;$EnableDepreciation:Company:##SVCurrentCompany

[System: UDF]
    DepRate1Half	: Number: 21005
	DepRate2Half	: Number: 21006

[#Part: Led Other Details]
    Add	: Line: FSDepRateChart, DepRate1Half, DepRate2Half
	
	[Line	: FSDepRateChart]
		Field: Medium Prompt 
		Local: Field: Medium Prompt: Set as: "Depriciation Rate"
;		Explode	: FSDepRateChart	: Yes
		
		[Part	: FSDepRateChart]
			Line	: DepRate1Half, DepRate2Half
			Scroll	: Vertical

			[Line: DepRate1Half]
				Field: Medium Prompt, DepRate1Half
				Local: Field: Medium Prompt: Set as: "for 1st Half"
				Local: Field: Medium Prompt: Align	: Right
;				Invisible	: Not @@IsEnableDepreciation

				[Field: DepRate1Half]
					Use			: Number Field
					Storage		: DepRate1Half
					Invisible	: Not @@IsEnableDepreciation
					Format		: "Percentage"
					Align		: Right
					
			[Line: DepRate2Half]
				Field: Medium Prompt, DepRate2Half
				Local: Field: Medium Prompt: Set as: "for 2nd Half"
				Local: Field: Medium Prompt: Align	: Right
				Invisible	: Not @@IsEnableDepreciation

				[Field: DepRate2Half]
					Use			: Number Field
					Set as		: If $$isEmpty:$DepRate2Half Then $DepRate1Half/2 Else $DepRate2Half
					Set Always	: Yes
					Storage		: DepRate2Half
					Invisible	: Not @@IsEnableDepreciation
					Format		: "Percentage"
					Align		: Right


[#Menu : Gateway of Tally]
	Option	: FS Depreciation Gateway		: @@IsEnableDepreciation
	
	[!Menu	: FS Depreciation Gateway]
		Add : Key Item : After : @@LocRatioAnalysis : Depreciation Chart	: H : Display : Dep Report

[Report : Dep Report]
	
	Use	 	 : DSP Template
	Variable : SVFromDate, SVToDate
;	Set      : SVfromDate 	: ##SVCurrentdate
;	Set      : SVToDate 	: ##SVCurrentdate
	Print Set	: Report Title		: "Depriciation Chart"
	Form     : Dep Form
	
[Form : Dep Form]
	Use 	    : DSP Template	
	Height 	    : 100% Screen
    Width	    : 100% Screen
	BackGround  : Lily White
	Space Top   : If $$InPrintMode Then 0.5 Else 0 inches
	Button      : PrintButton, ExportButton,F2 ChangePeriod
	Parts       : DSPAccTitles, DepinfoReport ;Dep Tit,
		
[Part : Dep Tit]
	
	Space Bottom : 0.2 inch
	Line : Dep Tit Line,DepDate
    
	
[Line : Dep Tit Line]
	
	Field : Dep Tit Field
	
[Field : Dep Tit Field]
	
	Use        : Name Field
	Set as     : "DEPRECIATION CHART"
	Align      : Center
	Full Width : Yes
	Style      : Large Bold

[Line : DepDate]
	
			 Space Top: 1% page
			 Field : DepFromdt,ToField,DepTodt
			 
[Field : DepFromdt]
	
   			  Use       : Uni Date Field 
	          Set as    : ##SVCurrentdate
	          Width     : 45% Screen
	          Align     : Center
	          Style     : Normal 
			  
[Field : ToField]
	
	Use    : Name Field
	Set as : "To"
	Width  : 4% Screen
	Align  : Center
	Style  : Normal

[Field : DepTodt]
	
	Use       : Uni Date Field 
	Set as    : ##SVToDate
	Width     : 45% Screen
	Align     : Center
	Style     : Normal 

[Part :  DepInfoReport]
	
	Line      		: FSDepcolumnTitles, FSDepInfo
	Repeat    		: FSDepInfo  : FSDepCollection    
	Scroll    		: Vertical
	Common Border 	: Yes
	Float     		: No
	Border    		: Thin Box
    Bottom Line		: FSDepColTotals
	Total 			: FSDepOpBal,FSDepAddition1Half,FSDepAddition2Half,FSDepSale,FSDepTotal,FSDepDepreciation,FSDepClosingBal

[Line : FSDepColumnTitles]
	Line : FSDepColumnTitles1, FSDepColumnTitles2

	[Line : FSDepColumnTitles1]
		Border : Thin Top
		Use		: FSDepInfo
	;	Fields : FSDepSerialNo,FSDepParticulars,FSDepDepRate,FSDepOpBal,FSDepAddition1Half,FSDepAddition2Half,FSDepSale,FSDepTotal,FSDepDepreciation,FSDepClosing Bal
		
		Local : Field : Default       			: Style 	 : Small Bold 
		Local : Field : Default	      			: Align 	 : Center
		Local : Field : Default	      			: Line		 : 0
		Local : Field : Default	      			: Delete	 : Border

		Local : Field : FSDepSerialNo     		: Info	 	 : "SNo." 
		Local : Field : FSDepParticulars   		: Info	 	 : "Particulars"
		Local : Field : FSDepDepRate      		: Info	 	 : "Dep"
		Local : Field : FSDepOpBal       		: Info	 	 : "Opening"
		Local : Field : FSDepAddition			: Info		 : "Addition"
		Local : Field : FSDepAddition			: Delete	 : Field
		Local : Field : FSDepAddition			: Sub Title	: Yes 
		Local : Field : FSDepSale  	      		: Info	 	 : "Sales/"
		Local : Field : FSDepTotal         		: Info	 	 : "Total"
		Local : Field : FSDepDepreciation  		: Info	 	 : "Depreciation"
		Local : Field : FSDepClosing Bal   		: Info	 	 : "W.D.V"

	[Line : FSDepColumnTitles2]
		Border : Thin Bottom
		Use		: FSDepInfo
	;	Fields : FSDepSerialNo,FSDepParticulars,FSDepDepRate,FSDepOpBal,FSDepAddition1Half,FSDepAddition2Half,FSDepSale,FSDepTotal,FSDepDepreciation,FSDepClosing Bal
		
		Local : Field : Default       			: Style 	 : Small Bold 
		Local : Field : Default	      			: Align 	 : Center
		Local : Field : Default	      			: Line		 : 0
		Local : Field : Default	      			: Delete	 : Border

		Local : Field : FSDepSerialNo     		: Info	 	 : "" 
		Local : Field : FSDepParticulars   		: Info	 	 : ""
		Local : Field : FSDepDepRate      		: Info	 	 : "Rate"
		Local : Field : FSDepOpBal       		: Info	 	 : "Balance"
		Local : Field : FSDepAddition1Half      : Info	 	 : "1st Half"
		Local : Field : FSDepAddition2Half      : Info	 	 : "2nd Half"
		Local : Field : FSDepSale  	      		: Info	 	 : "Transfer"
		Local : Field : FSDepTotal         		: Info	 	 : ""
		Local : Field : FSDepDepreciation  		: Info	 	 : ""
		Local : Field : FSDepClosing Bal   		: Info	 	 : ""
		Local : Field : FSDepAddition			: Border	 : Thin Top
	
[Line : FSDepInfo]

	Fields 		 : FSDepSerialNo, FSDepParticulars, 
	Right Field	 : FSDepDepRate, FSDepOpBal, FSDepAddition, FSDepSale, FSDepTotal, FSDepDepreciation, FSDepClosing Bal
	
	Option : FSAlterOnAltEnter
	Option : DisplayOnEnter

[!Line: FSAlterOnAltEnter]

    Key         : FSLine Object AltEnter Alter, Line Click Object Enter Alter

[Key   : FSLine Object AltEnter Alter]

    Key     : Alt + Enter
    Action  : Alter Object
    Mode    : Display
	
	[Field : FSDepSerialNo]
		Use    : Number Field
		Set as : $$Line
;		Width  : 4% Screen
		Style  : Normal
		Align	: Center

	[Field : FSDepParticulars]
		Use : Name Field
		Set as 	: $Name
		Full Width	: Yes
;		Width  	: 25% Screen
		Style  	: Normal
		Border 	: Thin Left
		Variable: LedgerName
		Modifies: LedgerName
		Alter	: Ledger
		Display	: Ledger Vouchers
	
	[Field : FSDepDepRate]
		Use : Number Field
		Set as : $DepRate1Half
;		Width  : 5% Screen
		Style  : Normal
		Border : Thin Left
		Format	: "Percentage"
		Align	: Right
		
	[Field : FSDepOpBal]
			
		Use    : Amount Field
		Set as : $BSOpening
;		Width  : 10% Screen
		Style  : Normal
		Border : Thin Left Right

	[Field	: FSDepAddition]
;		Use		: Name Field
		Field	: FSDepAddition1Half, FSDepAddition2Half,
		Width   : @@AmountWidth*2
		
		[Field : FSDepAddition1Half]
				
			Use    : Amount Field
			Set as : $$FromValue:@FSStartDate:$$ToValue:@FSMidDate:$BSDebits
			FSStartDate	: $$Date:"01-Apr-2012"
			FSMidDate	: $$Date:"30-Sep-2012"
			FSMidPeriod : $$Date:"01-Oct-2012"
			FSEndDate	: $$Date:"31-Mar-2013"
;			Width  : 10% Screen
			Style  : Normal
;			Border : Thin Left

		[Field : FSDepAddition2Half]
				
			Use    : Amount Field
			Set as : $$FromValue:@FSMidPeriod:$$ToValue:@FSEndDate:$BSDebits
			FSStartDate	: $$Date:"01-Apr-2012"
			FSMidDate	: $$Date:"30-Sep-2012"
			FSMidPeriod : $$Date:"01-Oct-2012"
			FSEndDate	: $$Date:"31-Mar-2013"
;			Width  : 10% Screen
			Style  : Normal
			Border : Thin Left
			
	[Field : FSDepSale]
			
		Use    : Amount Field
		Set as : $BSCredits
;		Width  : 10% Screen
		Style  : Normal
		Border : Thin Left
		
	[Field : FSDepTotal]
			
		Use 	: Amount Field
		Set as	: $$AsAmount:@MainDepTotal
		FirstDepTotal	: $$AmountAdd:#FSDepOpBal:#FSDepAddition1Half
		SecondDepTotal	: $$AmountAdd:@FirstDepTotal:#FSDepAddition2Half
		FirstDepSubTotal: @FirstDepTotal-#FSDepSale
		ThirdDepTotal	: If #FSDepSale < @FirstDepTotal Then @FirstDepTotal-#FSDepSale Else @SecondDepTotal-#FSDepSale
		MainDepTotal	: If #FSDepSale < @FirstDepTotal Then $$AmountAdd:@FirstDepSubTotal:#FSDepAddition2Half Else @SecondDepTotal-#FSDepSale
		FSFirstDepValue	: (@FirstDepSubTotal * $DepRate1Half)/100
		FSSecondDepValue: (#FSDepAddition2Half * $DepRate2Half)/100
		FSDepValue		: $$AmountAdd:@FSFirstDepValue:@FSSecondDepValue
;		Set as 	: ($BSOpening + $BSDebits) - $BSCredits 
;		Width 	: 12% Screen
		Style 	: Normal
		Border  :  Thin Left
		
	[Field : FSDepDepreciation]
			
		Use 	: Amount Field
		Set as	: $$FilterAmtTotal:FSDepriciationVchColl:IsFSLedExist:$FSTotalDrDepAmt
;		Set as 	: $$Round:@FSDepValue:1 ;(#FSDepTotal * #FSDepDepRate) / 100
		FirstDepTotal	: $$AmountAdd:#FSDepOpBal:#FSDepAddition1Half
		SecondDepTotal	: $$AmountAdd:@FirstDepTotal:#FSDepAddition2Half
		FirstDepSubTotal: @FirstDepTotal-#FSDepSale
		ThirdDepTotal	: If #FSDepSale < @FirstDepTotal Then @FirstDepTotal-#FSDepSale Else @SecondDepTotal-#FSDepSale
		MainDepTotal	: If #FSDepSale < @FirstDepTotal Then $$AmountAdd:@FirstDepSubTotal:#FSDepAddition2Half Else @SecondDepTotal-#FSDepSale
		FSFirstDepValue	: (@FirstDepSubTotal * $DepRate1Half)/100
		FSSecondDepValue: (#FSDepAddition2Half * $DepRate2Half)/100
		FSDepValue		: $$AmountAdd:@FSFirstDepValue:@FSSecondDepValue
;		
;		Width : 12% Screen
		Style 	: Normal
		Border  :  Thin Left

	[Field : FSDepClosing Bal]
		
		Use 	: Amount Field
		Set as 	: #FSDepTotal - #FSDepDepreciation
;		Width   : 12% Screen
		Style   : Normal
		Border  : Thin Left				
		
[Line: FSDepColTotals]

	Use   	:  FSDepInfo
	Border	: Column Titles
	Local	: Field	: Default			: Style		: Normal Bold
	Local : Field : FSDepSerialNo 		: Info		: "" 
	Local : Field : FSDepParticulars    : Info		: "Grand Total"
	Local : Field : FSDepDepRate 		: Info		: ""
	
	Local : Field : FSDepOpBal 			: Set as	: $$Total:FSDepOpBal
	Local : Field : FSDepAddition1Half	: Set as	: $$Total:FSDepAddition1Half
	Local : Field : FSDepAddition2Half	: Set as	: $$Total:FSDepAddition2Half
	Local : Field : FSDepTotal   		: Set as	: $$Total:FSDepTotal 
	Local : Field : FSDepSale    		: Set as	: $$Total:FSDepSale
	Local : Field : FSDepDepreciation   : Set as	: $$Total:FSDepDepreciation
	Local : Field : FSDepClosing Bal	: Set as	: $$Total:FSDepClosingBal

[Collection : FSDepcollection]
	
	Type		: Ledger 	
	Child Of	: $$GroupFixedAssets
	Belongs To	: Yes
	Fetch		: DepRate1Half, DepRate2Half
;	Filter		: FixedAssets Filter
	Sort		: @@Default		: $DepRate1Half
	
[System: Formula]
    FixedAssets Filter: $OpeningBalance > 0

[Collection	: FSDepriciationVchColl]
	Parm Var	: pvLedgerName		: String	: "Depreciation A/c"
	Parm Var	: pvDSPNameStyle		: String	: "Name Only"
	Type		: Vouchers			: Ledger
	Child Of	: ##pvLedgerName
	
	Belongs To	: Yes
	
	Fetch   	: Date, VoucherTypeName, VoucherNumber, Narration, MasterID
	Fetch   	: IsOptional
	Fetch		: AllLedgerEntries.BankAllocations.*
	Fetch		: AllLedgerEntries.BillAllocations.*
	Fetch		: AllLedgerEntries.LedgerName, AllLedgerEntries.Amount
	Fetch		: AllLedgerEntries.LedgerName, AllLedgerEntries.Narration, AllLedgerEntries.IsDeemedPositive ;;to get the narration in condensed mode.

	Compute		: TotalLedDrVchAmt    			: $$OrigVchLedDrTotal:#pvLedgerName:($$SysName:AcctgVchView)
	Compute		: TotalLedCrVchAmt    			: $$OrigVchLedCrTotal:#pvLedgerName:($$SysName:AcctgVchView)
	Compute		: VchLedName					: $$FuncDSPLedAccName:"No":##pvDSPNameStyle
	Compute		: FirstContraAccount			: $$FirstContraAcc:$$IsDr:@@TotalLedVchAmt
	Compute		: TotalLedVchAmt				: If $$InPrintMode Then $$OrigVchLedTotal:#pvLedgerName Else $$OrigVchLedTotal:##pvLedgerName
;	Compute		: DSPNameStyle					: ##DSPNameStyle
	
	Compute		: FSTotalDrDepAmt		: $$OrigVchLedDrTotal:##pvLedgerName
	Compute		: FSTotalCrDepAmt		: $$OrigVchLedCrTotal:##pvLedgerName
	Compute		: AllocCCLedName		: If $$IsEmpty:##pvLedgerName then "" else $$FuncDSPAccName:##pvLedgerName
;	Filter		: IsFSLedExist
	
[System: Formula]
	IsFSLedExist	: $VchLedName = "Computer A/c" ;#FSDepParticulars